import React from 'react';

export default class CommentBox extends React.Component {
  constructor(props) {
    super(props);
  }

  getParams(name,deflt) {
  	if(!deflt) {
  		deflt = null;
  	}
  	if(!this.props.data) {
  		return deflt;
  	}
  	
  	//return deflt;
  	return this.props.data.user.userinfo!=null?this.props.data.user.userinfo[name]:deflt;
  }

  render() {
    return (
      <div className="one_comment">
      	<div className="left_dl">
			<div className="author_info_header">
				<div className="img_header">
					<img src={this.getParams('headpic')} className="author_head"/>
				</div>
				<div className="author_name">
					<span>{this.getParams('nickName','正在加载...')}</span>
				</div>
			</div>
			<div className="clear"></div>
      	</div>
 		{this.props.isAuthor=='true'?<div className="isAuthor">楼主</div>:<div className="inAuthor">会员</div>}
      	<div className="right_dl">
      		<div className="comment_text"><span dangerouslySetInnerHTML={{__html:this.props.data!=null?this.props.data.context:''}}></span></div>
      		<div className="clear"></div>
      	</div>
      	<span className="comment_info floor">{this.props.data!=null?this.props.data.floor+'楼':''}</span>
      	<span className="comment_info ctime">{this.props.data!=null?'回复于：'+this.props.data.createTime:''}</span>
		<div className="clear"></div>
      </div>
    );
  }
}